package org.xingyun.dao;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.xingyun.bean.Cities;
import org.xingyun.utils.DataSourcesUtils;

import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.List;

public class CityDao {
    public List<Cities> selectAll(String id) throws SQLException {
        System.out.println("城市查询MySQL数据了");
        DataSource dataSource = DataSourcesUtils.getDataSource();
        QueryRunner queryRunner = new QueryRunner(dataSource);
        List<Cities> list = queryRunner.query("select * from cities where provinceid=?", new BeanListHandler<Cities>(Cities.class), id);
        return list;
    }
}
